package cn.com.java.service.impl;

import cn.com.java.mapper.ShoppingCartMapper;
import cn.com.java.mapper.SysUserMapper;
import cn.com.java.model.Order;
import cn.com.java.model.Product;
import cn.com.java.model.ShoppingCart;
import cn.com.java.model.SysUser;
import cn.com.java.service.OrderService;
import cn.com.java.service.ProductService;
import cn.com.java.service.ShoppingCartService;
import cn.com.java.service.SysUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liushuntao
 * @date 2024/3/19
 */
@Service
@RequiredArgsConstructor
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements ShoppingCartService {

    private final ProductService productService;


    @Override
    public String joinShoppingCar(Long userId, Long productId, Integer num) {
        ShoppingCart shoppingCart = new ShoppingCart();
        shoppingCart.setProductId(productId);
        shoppingCart.setStatus("0");
        shoppingCart.setCreateBy(userId.toString());
        shoppingCart.setNum(num);
        this.baseMapper.insert(shoppingCart);
        return "添加成功";
    }

    @Override
    public List<ShoppingCart> getByUserId(Long userId) {
        return this.baseMapper.selectByUserId(userId);
    }
}
